#include "family.h"
// 修改某成员信息
void FamilyTree::modifyMember(FamilyMember *member, const std::string &newName, const std::string &newBirthDate, const std::string &newContactInfo, const std::string &newIsMarried, const std::string &newIsAlive, const std::string &newDeathDate, const std::string &newFatherName, const std::string &newMotherName)
{
    if (member == nullptr)
    {
        std::cerr << "成员不存在，无法修改。" << std::endl;
        return;
    }

    // 只有当新值不为空时，才更新相应字段
    if (!newName.empty())
    {
        member->name = newName;
    }
    if (!newBirthDate.empty())
    {
        member->birthDate = newBirthDate;
    }
    if (!newContactInfo.empty())
    {
        member->contactInfo = newContactInfo;
    }
    if (!newIsMarried.empty())
    {
        member->isMarried = (newIsMarried == "Yes");
    }
    if (!newIsAlive.empty())
    {
        member->isAlive = (newIsAlive == "Yes");
    }
    if (!newDeathDate.empty())
    {
        member->deathDate = newDeathDate;
    }
    if (!newFatherName.empty())
    {
        member->fatherName = newFatherName;
    }
    if (!newMotherName.empty())
    {
        member->motherName = newMotherName;
    }

    std::cout << "成员信息已更新。" << std::endl;
}